<?php

    require_once '../lib/maikuro/db/SqlitePDO.php';
    $db = new SqlitePDO(realpath('./app/etc') . '/example.sqlite');

    
    // Set up some example data in the form of column => value
    $exampleData = array(
        array('exampleColumn' => 'Example data 1'),
        array('exampleColumn' => 'Example data 2'),
    );

    // Start a database transaction which allows for multiple queries to be
    // executed in the same transaction.
    $db->beginTransaction();
    foreach ($exampleData as $values) {
        // The extended PDO class contains an insert() method.
        $db->insert('exampleTable', $values);
    }
    $db->commit();

    // The extended PDO class contains a select() method that returns a
    // PDOSelectQuery object which can be used to build an SQL SELECT query.
    $result = $db->select()->from('exampleTable')
                           ->orderBy('exampleColumn')
                           ->fetchAll();

    // The result is returned as an array of StdClass objects.
    foreach ($result as $row) {
        echo 'id: ' . $row->id . ' exampleColumn: ' . $row->exampleColumn . '<br />';
    }

    // The extended PDO class contains a delete() method which will delete all
    // or selected rows from the table.
    $rowCount = $db->delete('exampleTable');

    // The number of affected rows is returned:
    echo 'The number of affected rows is: ' . $rowCount;



